def compare = {val1,val2->
    def tolerance = 0.0003
    return (((val1>=val2-tolerance)&&(val1<=val2+tolerance))?true:false)
}

//def files = ['q.value.BREAST-CNS.txt']

def files = ['q.value.all.txt',
'p.value.CNS-LEUK.txt',
'p.value.COLON-PROSTATE.txt',
'p.value.MELAN-RENAL.txt',
'q.value.BREAST-MELAN.txt',
'q.value.CNS-PROSTATE.txt',
'q.value.LEUK-OVAR.txt',
'q.value.OVAR-PROSTATE.txt',
'p.value.BREAST-CNS.txt',
'p.value.CNS-MELAN.txt',
'p.value.COLON-RENAL.txt',
'p.value.NSCLC-OVAR.txt',
'q.value.BREAST-NSCLC.txt',
'q.value.CNS-RENAL.txt',
'q.value.LEUK-PROSTATE.txt',
'q.value.OVAR-RENAL.txt',
'p.value.BREAST-COLON.txt',
'p.value.CNS-NSCLC.txt',
'p.value.LEUK-MELAN.txt',
'p.value.NSCLC-PROSTATE.txt',
'q.value.BREAST-OVAR.txt',
'q.value.COLON-LEUK.txt',
'q.value.LEUK-RENAL.txt',
'q.value.PROSTATE-RENAL.txt',
'p.value.BREAST-LEUK.txt',
'p.value.CNS-OVAR.txt',
'p.value.LEUK-NSCLC.txt',
'p.value.NSCLC-RENAL.txt',
'q.value.BREAST-PROSTATE.txt',
'q.value.COLON-MELAN.txt',
'q.value.MELAN-NSCLC.txt',
'p.value.BREAST-MELAN.txt',
'p.value.CNS-PROSTATE.txt',
'p.value.LEUK-OVAR.txt',
'p.value.OVAR-PROSTATE.txt',
'q.value.BREAST-RENAL.txt',
'q.value.COLON-NSCLC.txt',
'q.value.MELAN-OVAR.txt',
'p.value.BREAST-NSCLC.txt',
'p.value.CNS-RENAL.txt',
'p.value.LEUK-PROSTATE.txt',
'p.value.OVAR-RENAL.txt',
'q.value.CNS-COLON.txt',
'q.value.COLON-OVAR.txt',
'q.value.MELAN-PROSTATE.txt',
'p.value.BREAST-OVAR.txt',
'p.value.COLON-LEUK.txt',
'p.value.LEUK-RENAL.txt',
'p.value.PROSTATE-RENAL.txt',
'q.value.CNS-LEUK.txt',
'q.value.COLON-PROSTATE.txt',
'q.value.MELAN-RENAL.txt',
'p.value.BREAST-PROSTATE.txt',
'p.value.COLON-MELAN.txt',
'p.value.MELAN-NSCLC.txt',
'q.value.BREAST-CNS.txt',
'q.value.CNS-MELAN.txt',
'q.value.COLON-RENAL.txt',
'q.value.NSCLC-OVAR.txt',
'p.value.BREAST-RENAL.txt',
'p.value.COLON-NSCLC.txt',
'p.value.MELAN-OVAR.txt',
'q.value.BREAST-COLON.txt',
'q.value.CNS-NSCLC.txt',
'q.value.LEUK-MELAN.txt',
'q.value.NSCLC-PROSTATE.txt',
'p.value.CNS-COLON.txt',
'p.value.COLON-OVAR.txt',
'p.value.MELAN-PROSTATE.txt',
'q.value.BREAST-LEUK.txt',
'q.value.CNS-OVAR.txt',
'q.value.LEUK-NSCLC.txt',
'q.value.NSCLC-RENAL.txt']

files.each{path->
    println 'Comparison of '+path
    def fileAmin = new File('/home/auerf/Comparison/FULL Proteome/all_pairwise_celllines/amin/'+path)
    def dataAmin = [:]
    fileAmin.each{line->
        def splitted = line.split('\t')
        if(splitted[1]!='NA'){
            dataAmin.put(splitted[0], splitted[1].replace(',','.').toDouble())
        }else{
//            println line
        }
    }
    def fileMe = new File('/home/auerf/Comparison/FULL Proteome/all_pairwise_celllines/me/'+path)
    def dataMe = [:]
    fileMe.each{line->
        def splitted = line.split('\t')
        dataMe.put(splitted[0], splitted[1].toDouble())
    }
//    println 'Amin: '+dataAmin.size()+'\tMe: '+dataMe.size()

    println 'File Length is equal: '+(dataMe.size()==dataAmin.size())

    def error = [:]
    dataAmin.sort{it.key}.each{id, value->
        def diff = Math.abs(value-dataMe[id]).round(3)
        if(!error.containsKey(diff)){error.put(diff, 0)}
        error[diff]++
        if(diff==0.554){
            println id
        }
    }
    error.sort{it.key}.each{k,v-> println 'Error: '+k+'\t'+v}
}